/*
 * @Author: wei_jt@ecidi.com
 * @Date: 2019-11-28 10:42:58
 * @LastEditors: wei_jt@ecidi.com
 * @LastEditTime: 2022-04-11 14:20:45
 * @Description:  全局配置入口
 */
import FawkesLib from 'fawkes-lib' //组件库
import { SvgIcon, ExcelExport, FksWebsocket, ModuleView } from '@/components'

import { nodePermission, redirectTo } from '@/permission'
import Directives from '@/directives'
import Filters from '@/filters'
import Decorators from '@/decorators'

import request from '@/utils/request' //axios封装
import { themeInit } from '../theme'
import { transDate } from '../timezone'
import mixin from '@/mixins/default' //全局混入
import storage from '../storage'
import tinymce from 'tinymce'
import VueTinymce from '@packy-tang/vue-tinymce'
import xss from 'xss'


Window.prototype.ModuleView = ModuleView
const plugin = {}
plugin.install = function (Vue) {
  Vue.mixin(mixin)



  !Vue.prototype.$InQianKun && import('fawkes-lib/lib/theme-chalk/index.css').then(() => {
    themeInit()
  })



  Vue.component('svg-icon', SvgIcon) //在线svg组件注册，本地模块可改为离线svg组件
  Vue.component('excel-export', ExcelExport)

  //svg载入

  const req = require.context('@/assets/svg', true, /\.svg$/)
  const requireAll = (requireContext) =>
    requireContext.keys().map(requireContext)
  requireAll(req)

  Vue.use(Directives)
  Vue.use(Filters)
  Vue.use(Decorators)

  Vue.prototype.$FksWebsocket = FksWebsocket
  Vue.prototype.$axios = request
  Vue.prototype.nodePermission = nodePermission
  Vue.prototype.redirectTo = redirectTo

  Vue.prototype.$storage = storage
  Vue.prototype.$transDate = transDate
  Vue.prototype.xss = xss
  Vue.prototype.$tinymce = tinymce // 将全局tinymce对象指向给Vue作用域下
  Vue.use(VueTinymce)

  //fawkes组件库
  Vue.use(FawkesLib, {
    preciseSearch: true,
    hideSwitch: true
  })
}
export default plugin
